package ejb.dao;

import ejb.entities.User;
import java.util.HashMap;
import java.util.Map;
import javax.ejb.Stateless;


@Stateless
public class UserDAO extends GenericDAO<User> {
	public UserDAO() {
		super(User.class);
	}

        public User findUserByUsername(String username) {
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("username", username);
		String query = "select u from User u where u.username = :username";
		return super.findOneResult(query, parameters);
	}
        
	public User findUserByEmail(String email) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("email", email);
		String query = "select u from User u where u.email = :email";
		return super.findOneResult(query, parameters);
	}

}
